/**
 * 
 */
package org.dragonfire.dasm.directives;

import java.util.ArrayList;

import org.dragonfire.dasm.Command;
import org.dragonfire.dasm.Listing;
import org.dragonfire.dasm.DirectiveManager.Directive;

/**
 * Executes a string with the preprocessor as if it was the current line of the
 * current file<br />
 * <br />
 * Format:<br />
 * <code>#EXEC <i>&lt;arg1&gt;</i>[,<i>&lt;arg2&gt;</i>[,<i>...</i>]]</code><br />
 * <br />
 * Parameters:<br />
 * <table>
 * <tr>
 * <td><code>arg1</code></td>
 * <td>(String) The string to preprocess</td>
 * </tr>
 * </table><br />
 * Errors:<br />
 * <table>
 * <tr>
 * <td><code>ERROR_STRING_REQUIRED</code></td>
 * <td>Thrown if <code>arg1</code> is not a string</td>
 * </tr>
 * </table>
 * 
 * @see org.dragonfire.dasm.preprocessor.Preprocessor#preprocessLine(String)
 * @author Darth Android
 * @version 2.0
 */
public class Exec extends Directive {

	public ArrayList<Listing> pass1(Command c) {
		ArrayList<Listing> list = new ArrayList<Listing>();
		for (int i = 0; i < c.getParams().length; i++) {
			list.addAll(getPreprocessor().preprocessLine(evalString(c.getParam(i))));
		}
		return list;
	}
}
